﻿namespace EasyGo.Logic.Model
{
    using System;
    using EasyGo.Common.Commands;
    using EasyGo.Common.ValueTypes;

    public class Task : Entity
    {
        public string Summary { get; set; }

        public string Description { get; set; }

        public int ProjectId { get; set; }

        public DateTime AddDate { get; set; }

        public DateTime UpdateDate { get; set; }

        public int Status { get; set; }

        public int? AssignedId { get; set; }

        public int ReporterId { get; set; }

        public int Priority { get; set; }

        public int? ComponentId { get; set; }

        public DateTime? DueDate { get; set; }

        public void Initialize(CreateTaskCommand command, int reporterId)
        {
            this.Summary = command.Summary;
            this.Description = command.Description;
            this.Status = (int)TaskStatus.Awaiting;
            this.AddDate = DateTime.Now;
            this.UpdateDate = DateTime.Now;
            this.DueDate = command.DueDate;
            this.ProjectId = command.ProjectId;
            this.ReporterId = reporterId;
            this.Priority = (int)TaskPriority.Normal;
        }
    }
}